package next.control.support;

import next.TemplateActivity.R;
import next.control.ApplicationController;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TableRow;



public class DemoPopupWindow extends BetterPopupWindow  {

	public DemoPopupWindow(View anchor, int cual) {
		super(anchor, cual);
	}

	@Override
	protected void onCreate(int whichButton) {
			
		//--inflate layout
		LayoutInflater inflater = (LayoutInflater) this.anchor.getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		ViewGroup root = null;

		switch (whichButton) {
		case 1:
			root = (ViewGroup) inflater.inflate(
					R.layout.generic_popup_grid_custom_profile, null);
			break;
		case 2:
			
			root = (ViewGroup) inflater.inflate(
					R.layout.generic_popup_grid_custom_orders, null);
			break;
		case 3:
			
			root = (ViewGroup) inflater.inflate(
					R.layout.generic_popup_grid_custom_preferences, null);
			break;
		case 4:
			
			root = (ViewGroup) inflater.inflate(
					R.layout.generic_popup_grid_custom_search, null);
			break;

		default:
			// root = (ViewGroup) inflater.inflate(R.layout.popup_grid_layout_profile, null);
			break;
		}

		// setup button events
		for (int i = 0, icount = root.getChildCount(); i < icount; i++) {
			View v = root.getChildAt(i);

			if (v instanceof TableRow) {
				TableRow row = (TableRow) v;

				for (int j = 0, jcount = row.getChildCount(); j < jcount; j++) {
					View item = row.getChildAt(j);
					if (item instanceof Button) {
						Button b = (Button) item;
						b.setOnClickListener(ApplicationController.getInstance());
					}
				}
			}
		}

		// set the inflated view as what we want to display
		this.setContentView(root);
	}

}
